package com.guaju.yueshangLife.activity;

import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.githang.statusbar.StatusBarCompat;
import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.base.MyAppcomActivity;
import com.guaju.yueshangLife.databinding.ActivityBillBinding;

public class BillActivity extends MyAppcomActivity {

    private ActivityBillBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_bill);
        StatusBarCompat.setStatusBarColor(this, getResources().getColor(R.color.white));
        initView();
        initListener();

    }

    private void initListener() {
        binding.rgBillSelection.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId==R.id.rb_bill_no){
                    binding.llBillDetail.setVisibility(View.GONE);
                }else{
                    binding.llBillDetail.setVisibility(View.VISIBLE);
                }
            }
        });


        binding.rgBill.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId==R.id.rb_bill_company){
                    binding.llBillCompany.setVisibility(View.VISIBLE);
                }else{
                    binding.llBillCompany.setVisibility(View.GONE);
                }
            }
        });
    }

    private void initView() {
        TextView top_tv_title =binding.top.findViewById(R.id.top_tv_title);
        binding.rbBillPersonal.setChecked(true);
        binding.llBillCompany.setVisibility(View.GONE);
        binding.rbBillNo.setChecked(true);
        binding.llBillDetail.setVisibility(View.GONE);
        top_tv_title.setText("发票");
        binding.top.findViewById(R.id.fl_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
